//
//  GZUser.swift
//  sinaweibo
//
//  Created by mac book pro on 16/3/26.
//  Copyright © 2016年 finish. All rights reserved.
//

import UIKit

class GZUser: NSObject {
    /// 用户Uid
    var id: Int = 0
    /// 友好显示名称
    var name: String?
    /// 用户头像地址（中图） 50x50
    var profile_image_url: String?
    /// 用户头像URL
    var profileImageUrl: NSURL?{
        if let urlstring = profile_image_url{
            return NSURL(string: urlstring)
        }
        return nil
    }
    /// 是否是微博认证用户，即加V用户，true：是，false：否
    var verified: Bool = false
    /// verified_type 没有认证:-1   认证用户:0  企业认证:2,3,5  达人:220
    var verified_type: Int = -1
    /// 认证图片，不用到cell的时候在计算，特别在滚动的时候损耗性能
    var verified_typeImage: UIImage?{
        switch verified_type {
        case 0:
            return UIImage(named: "avatar_vip")
        case 2,3,5:
            return UIImage(named: "avatar_enterprise_vip")
        case 220:
            return UIImage(named: "avatar_grassroot")
        default:
            return nil
        }
    }
    /// 会员等级 1-6
    var mbrank: Int = 0
    /// 会员等级图片
    var mbrankImage: UIImage?{
        if mbrank > 0 && mbrank <= 6 {
            return UIImage(named: "common_icon_membership_level\(mbrank)")
        }
        
        return nil
    }
    init(dict: [String:AnyObject]){
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        
    }
    override  var description: String{
        get{
            
            let properties = ["id", "name", "profile_image_url", "verified_type", "mbrank"]
            return "\n\t\t:用户模型:\(dictionaryWithValuesForKeys(properties))\n"
        }
    }
    
}
